﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel;

namespace MvcShop.Models
{
    [MetadataType(typeof(OrdersMetadata))]
    public partial class Orders
    {
    }

    public class OrdersMetadata
    {
        [Required(ErrorMessage = "客户名称不能为空.")]
        [StringLength(50, ErrorMessage = "客户名称不能超过50个字节.")]
        public string CustomerName { get; set; }

        [Required(ErrorMessage = "通讯地址不能为空.")]
        [StringLength(50, ErrorMessage = "通讯地址不能超过100个字节.")]
        public string Address { get; set; }

        [Required(ErrorMessage = "邮编不能为空.")]
        [RegularExpression(@"^[1-9]\d{5}$", ErrorMessage = "请输入正确的邮编地址.")]
        public int Postalcode { get; set; }

        [Required(ErrorMessage = "联系电话不能为空.")]
        [RegularExpression(@"^(13[0-9]|15[0|3|6|7|8|9]|18[8|9])\d{8}$", ErrorMessage = "请输入正确的手机号码.")]
        public string Phone { get; set; }

        [Required(ErrorMessage = "邮件地址不能为空.")]
        [RegularExpression(@"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", ErrorMessage = "请输入正确的邮件地址.")]
        public string Email { get; set; }

        [Required(ErrorMessage = "送货方式不能为空.")]
        public int DId { get; set; }

        [StringLength(100, ErrorMessage = "备注不能超过100个字节")]
        public string Remark { get; set; }
    }

    [MetadataType(typeof(AddressBookMetadata))]
    public partial class AddressBook
    { }

    public class AddressBookMetadata
    {
        [DisplayName("用户名称")]
        [Required(ErrorMessage = "用户名称不能为空。")]
        [StringLength(50, ErrorMessage = "用户名称不能超过50个字节。")]
        public string UserName { get; set; }

        [DisplayName("姓名")]
        [Required(ErrorMessage = "客户名称不能为空。")]
        [StringLength(50, ErrorMessage = "客户名称不能超过50个字节。")]
        public string CustomerName { get; set; }

        [DisplayName("地址")]
        [Required(ErrorMessage = "地址不能为空。")]
        [StringLength(50, ErrorMessage = "地址不能超过100个字节。")]
        public string Address { get; set; }

        [DisplayName("省份")]
        [Required(ErrorMessage = "必须提供该地址所在的省、市及行政区信息。")]
        [StringLength(50, ErrorMessage = "省份不能超过50个字节。")]
        public string Province { get; set; }

        [DisplayName("城市")]
        [StringLength(50, ErrorMessage = "城市不能超过50个字节。")]
        public string City { get; set; }

        [DisplayName("地区")]
        [StringLength(50, ErrorMessage = "地区不能超过50个字节。")]
        public string County { get; set; }

        [DisplayName("邮编")]
        [Required(ErrorMessage = "邮编不能为空。")]
        [RegularExpression(@"^[1-9]\d{5}$", ErrorMessage = "请输入正确的邮编地址。")]
        public int Postalcode { get; set; }

        [DisplayName("电话")]
        [Required(ErrorMessage = "电话不能为空。")]
        [RegularExpression(@"^(13[0-9]|15[0|3|6|7|8|9]|18[8|9])\d{8}$", ErrorMessage = "请输入手机号码。")]
        public string Phone { get; set; }
    }
}
